#ifndef TD_SCREEN_H_
#define TD_SCREEN_H_

/************************************************************************/
/* STL                                                                  */
/************************************************************************/
#include <string> 
#include <vector>
#include <map>
#include <sstream>

/************************************************************************/
/* SDL                                                                  */
/************************************************************************/
#include "SDL/SDL.h"
#include "SDL_ttf/SDL_ttf.h"
#include "SDL_mixer/SDL_mixer.h" 

/************************************************************************/
/* Resources                                                            */
/************************************************************************/
#include "Resources/Images/SDLImage.h"
#include "Resources/Tiles/Tile.h"
#include "Resources/ResourceManager.h"

/************************************************************************/
/* Core                                                                 */
/************************************************************************/
#include "Core/BaseEntity.h"
#include "Core/Timer.h"

/************************************************************************/
/* Game objects                                                         */
/************************************************************************/
#include "Game/Game Objects/Marios/BaseMario.h"
#include "Game/Managers/MarioManager.h"
#include "Game/Managers/TowerManager.h"

#ifdef _WII
	#include <gccore.h>
#endif


using namespace std;
using namespace TD_Resources;
using namespace TD_GUI;

namespace TD_Game {
	class Screen {
		
		/************************************************************************/
		/* Definitions                                                          */
		/************************************************************************/
		const static Coord2D m_statusBarPos; 
		const static Coord2D m_rightMenuPos;
		const static Coord2D m_infoBarPos;
		const static Coord2D m_drawingCanvasPos;
		const static Coord2D m_canvasPos;
		const static Coord2D m_canvasBounds; 
		

		/**Timer and frame rate capping info*/
		Timer fps;
		Timer update;
		int m_frame;
		unsigned int m_lastTick;

		/**Fonts */
		TTF_Font *m_pStatusFont;
		
		/**Boolean that dictates if the SDL SDK is initialized.*/
		bool m_isSDLInitialized;
		
		/**Render map for the screen.*/
		vector <Tile *> m_renderVector;
		map <string , Tile *> m_renderMap;
		vector <BaseMario *> m_creepVector;
		
		/**SDL root.*/
		SDL_Surface *m_screenRoot; 
		
		/************************************************************************/
		/* Private functions                                                    */
		/************************************************************************/
		/**SDL Initialization function.*/
		bool initSDL(const string &screenCaption, unsigned int screenWidth, unsigned int screenHeight, unsigned int screenBpp);
		
		Tile * findBaseEntity(const string &entName);
	public:

		/************************************************************************/
		/* Constructors				                                            */
		/************************************************************************/
		Screen(const string &screenCaption, unsigned int screenWidth, unsigned int screenHeight, unsigned int screenBpp);
		
		~Screen();
		
		/************************************************************************/
		/* Access functions                                                     */
		/************************************************************************/
		inline SDL_Surface * getRootScreen() const {
			return (m_screenRoot);
		}

		const Coord2D & getCanvasPosition() const {
			return(m_canvasPos); //Border
		}
		const Coord2D & getCanvasBounds() const {
			return(m_canvasBounds);
		}

		/************************************************************************/
		/* Functionalities                                                      */
		/************************************************************************/
		bool addImage(const Coord2D &position, const string &imageFile);
		bool addImage(const Coord2D &position, const string &imageFile, const string &objName);
		
		bool setStatusBarImage(const string &imageFile);

		bool setRightMenuImage(const string &imageFile);

		bool setCanvasImage(const string &imageFile);

		bool setInfoBarImage(const string &imageFile);

		bool setBackgroundImage(const string &imageFile);
		
		void addToRender(Tile *renderEnt);
	
		/************************************************************************/
		/* Rendering functions                                                  */
		/************************************************************************/
		void render(unsigned int deltaTime);
	};
}
#endif